package ObjectPackage;

import java.util.Calendar;
import java.util.Scanner;

public class ObjectClass 
{

	public ObjectClass() 
	{
	}

	 public enum Special{MAKEUP, HAIRDRESSER, MASSEUR,UNKNOWN};
	 public  Special special;

     private  String Surname;
     private  String Name;
     private  String MasterName;
     private  Calendar date;
     private  String time;
     final  int field_count =6;
     
      ObjectClass ob;
    
     public Special getSpecial(){
             return special;
     }
     
	public  void setSpecial(String aSpecial){
             try{
                     special =Special.valueOf(aSpecial);                    
             }
             catch(Exception e){
                     System.out.println("Wrong Special!");
                     special = Special.UNKNOWN;
             }
     }
     public String getSurname(){
             return Surname;
     }
     public  void setSurname(String aSurname){
             Surname = aSurname;
     }
     public String getName(){
             return Name;
     }
     public  void setName(String aName){
             Name = aName;
     }
     public String getMasterName(){
         return MasterName;
	 }
	 public  void setMasterName(String aMasterName){
	         MasterName = aMasterName;
	 }
     public String getDate(){
             return conversion.parseCalendarToString(date);
     }
     public  void setDate(String aDate){
             date = conversion.parseStringToDate(aDate);
     }
     public String getDTime(){
             return time;
     }
     public  void setTime(String aTime){
             time = conversion.parseStringToTime(aTime);
     }
     /*
      *@parametr String 
      */
     public void fillObject(String detail){
             String str[]= detail.split(" ");
             setSurname(str[0]);
             setName(str[1]);
             setSpecial(str[2]);
             setMasterName(str[3]);
             setDate(str[4]+" "+str[5]);
             if(str.length == field_count)
                     setTime(str[4]+" "+str[5]);
     }
     
     /*
      *@parametr OblectClass 
      */
     public void fillObject(ObjectClass detail){
         Surname=detail.getSurname();
         Name=detail.getName();
         special= detail.getSpecial();
         MasterName=detail.getMasterName();
         date=conversion.parseStringToDate(detail.getDate());
         time=detail.getDTime();
 }
    
       
     public  String ToString(){
    	
             return  Surname +" "+ Name +" "+special+" "+ MasterName +" "+ conversion.parseCalendarToString(date)+" "+time;
     }
	
	public ObjectClass getNew(ObjectClass ob) {
		setNew(ob);
		ToString();
		return ob;
	}
	

	 /*
     *@Parameter OblectClass 
     */
	@SuppressWarnings("resource")
	private void setNew(ObjectClass ob) {
		
		Scanner c;
		String st ;
		System.out.print("Surnam:  ");
		c= new Scanner(System.in);
		st =c.nextLine();
		ob.setSurname(st);
		System.out.print("Name:  ");
		c= new Scanner(System.in);
		st =c.nextLine();
		ob.setName(st);
        System.out.print("Special:  ");
        c= new Scanner(System.in);
        st =c.nextLine();
        ob.setSpecial(st);
        System.out.print("MasterName:  ");
        c= new Scanner(System.in);
        st =c.nextLine();
        ob.setMasterName(st);
        System.out.print("Date in format \"yyyy.mm.dd hh:mm\":  ");
        c= new Scanner(System.in);
        st =c.nextLine();
        ob.setDate(st);
        ob.setTime(st);
		
	}
}
